<template>
	<!-- 经营业户查询 -->
	<view class="personnel-evaluation">
		<view class="search-box">
			<view class="search-item">
				<view class="label">
					经营业户名称
				</view>
				<view class="content">
					<input class="uni-input" placeholder="请输入经营业户名称" v-model="searchData.name" />
				</view>
			</view>
			<view class="search-item">
				<view class="label">
					经营许可证号
				</view>
				<view class="content">
					<input class="uni-input" placeholder="请输入经营许可证号" v-model="searchData.num" />
				</view>
			</view>
			<view class="search-item">
				<view class="label">
					<image class="base64" :src="base64" mode="" @click="getImgCode"></image>
				</view>
				<view class="content">
					<input class="uni-input" placeholder="请输入验证码" v-model="searchData.code" />
				</view>
			</view>
			<view class="search-btn">
				<view class="submit" @click="submitHandle">查询</view>
				<view class="reset" @click="resetHandle">重置</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				searchData: {
					name: "",
					num: "",
					code: "",
					key: '',
				},
				base64: ""
			}
		},
		methods: {
			submitHandle() {
				if (!this.searchData.name) {
					uni.showToast({
						title: "请输入经营业户名称",
						icon: 'none'
					});
					return;
				}
				if (!this.searchData.num) {
					uni.showToast({
						title: "请输入经营许可证号",
						icon: 'none'
					});
					return;
				}
				this.$api.businessOwner(this.searchData).then(res => {
					// console.log(res);
					if (!res.data.data || Object.keys(res.data.data).length == 0) {
						uni.showToast({
							title: '暂无数据',
							duration: 1500,
							icon:'none',
						});
						return false;
					}
					this.$store.commit('set_tempData', res.data.data);
					this.$goBack('/pages/dgs_qy/info-search/result/business-operators');
				})
			},
			resetHandle() {
				Object.assign(this.searchData, {
					name: "",
					num: "",
					code: "",
				})
			},
			getImgCode() {
				this.$api.getCode().then(res => {
					const resData = res.data;
					// console.log(resData);
					this.base64 = resData.image;
					this.searchData.key = resData.key;
				}).catch(() => {})
			}
		},
		mounted() {
			this.getImgCode()
		}
	}
</script>

<style lang="scss">
	.personnel-evaluation {
		padding: 40rpx 30rpx;
	}

	.search-item {
		display: flex;
		align-items: center;
		margin-bottom: 36rpx;

		.label {
			width: 230rpx;
			font-size: 28rpx;
			color: #333;
			line-height: 28rpx;
			display: flex;
			align-items: center;

			.img-icon {
				margin-right: 10rpx;
			}

			.base64 {
				height: 76rpx;
				width: 152rpx;
			}
		}

		.content {
			flex: 1;

			input {
				box-sizing: border-box;
				height: 76rpx;
				line-height: 76rpx;
				padding: 0 28rpx;
				border-radius: 8rpx;
				background: #F5F5F5;
				width: 100%;
			}
		}
	}

	.search-btn {

		.submit,
		.reset {
			margin: 0 auto;
			width: 70%;
			border-radius: 8rpx;
			height: 76rpx;
			line-height: 76rpx;
			text-align: center;
			font-size: 32rpx;
			color: #333;
		}

		.submit {
			background: #007AFF;
			color: #FFFFFF;
			margin-bottom: 26rpx;
		}

		.reset {
			// background: #007AFF;
			color: #2084FF;
			background: rgba(32,132,255,0.04);
			border: 2rpx solid #2084FF;
		}
	}
</style>
